package com.hotel.tv.runtime.session.impl;

import com.autumn.security.session.ShiroAutumnSession;
import com.hotel.tv.constants.HotelUserTypeConstant;
import com.hotel.tv.runtime.session.HotelSession;

/**
 * 会话抽象
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-04-02 21:44
 **/
public abstract class AbstractHotelSession extends ShiroAutumnSession implements HotelSession {

    @Override
    public Integer getUserType() {
        return this.getIdentityClaims().getIntegerClaims(FIELD_USER_TYPE);
    }

    @Override
    public boolean isAdminUser() {
        Integer userType = this.getUserType();
        return userType != null && (userType.equals(HotelUserTypeConstant.ADMIN)
                || userType.equals(HotelUserTypeConstant.HOTEL_ADMIN));
    }

    @Override
    public boolean isClientUser() {
        Integer userType = this.getUserType();
        return userType != null && userType.equals(HotelUserTypeConstant.USER);
    }
}
